package com.bao.demo.work.flower.service.impl;

import com.bao.demo.work.flower.dao.impl.FlowerDaoImpl;
import com.bao.demo.work.flower.entity.Flower;
import com.bao.demo.work.flower.service.FlowerService;

import java.util.List;

/**
 * @author baoye
 * @date 2024-08-23/19:51
 */
public class FlowerServiceImpl implements FlowerService {

    @Override
    public List<Flower> selectAllFlower(String sql) {
        try {
            return FlowerDaoImpl.class.newInstance().selectAllFlower(sql);
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public Flower selectFlowerById(String sql, int id) {
        try {
            return FlowerDaoImpl.class.newInstance().selectFlowerById(sql,id);
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public int update(String sql, Flower flower, int id) {
        try {
            FlowerDaoImpl flowerDao = FlowerDaoImpl.class.newInstance();
            return flowerDao.update(sql,flower,id);
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public int delete(String sql, int id) {
        try {
            return FlowerDaoImpl.class.newInstance().delete(sql,id);
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return 0;
    }
}
